Skip to content

[PENDING VALIDATION] Factor large repeated values in manifests#1186

Closed
vicb wants to merge 1 commit intomainfrom
vicb/dedup
Closed

[PENDING VALIDATION] Factor large repeated values in manifests#1186
vicb wants to merge 1 commit intomainfrom
vicb/dedup

Conversation

@vicb
Copy link
Copy Markdown
Contributor

@vicb vicb commented Apr 10, 2026

There could be large repeared values in page_client-reference-manifest.js manifests.

This PR factor those values into separate variables to reduce the generated code size.

// ## Original code

globalThis.__RSC_MANIFEST["/page-240/page"] = {
    "moduleLoading": {
        "prefix": "",
        "crossOrigin": null
    },
    "clientModules": {
      // large value
    },
    "ssrModuleMapping": {
      // large value
    },
    "edgeSSRModuleMapping": {},
    "rscModuleMapping": {
      // large value
    },
    "edgeRscModuleMapping": {},
    "entryCSSFiles": {
        "[project]/app/favicon.ico": [],
        "[project]/node_modules/.pnpm/next@16.1.6_@babel+core@7.29.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/next/dist/client/components/builtin/global-error": [],
        "[project]/app/page-240/page": []
    },
    "entryJSFiles": {
        "[project]/app/favicon.ico": ["static/chunks/33074d3ff5d0cd2d.js", "static/chunks/eb1e789fab5a5185.js"],
        "[project]/node_modules/.pnpm/next@16.1.6_@babel+core@7.29.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/next/dist/client/components/builtin/global-error": [],
        "[project]/app/page-240/page": ["static/chunks/ac1a1e8b1e840533.js"]
    }
};
        
// ## Code with values factored out
const  v_c9e580fbbdad93172b59e4c2f3cc639252131ede = {
  // large value
};       
const  v_de230b1b5e02082d7a5ca6eff1215904a2545bb9 = {
  // large value
};       
const  v_e7cdc68a12f3e69937d7959a7aaafa15b61e4274 = {
  // large value
};       

// [ ...]

globalThis.__RSC_MANIFEST["/page-240/page"] = {
    "moduleLoading": {
        "prefix": "",
        "crossOrigin": null
    },
    "clientModules": v_c9e580fbbdad93172b59e4c2f3cc639252131ede,
    "ssrModuleMapping": v_de230b1b5e02082d7a5ca6eff1215904a2545bb9,
    "edgeSSRModuleMapping": {},
    "rscModuleMapping": v_e7cdc68a12f3e69937d7959a7aaafa15b61e4274,
    "edgeRscModuleMapping": {},
    "entryCSSFiles": {
        "[project]/app/favicon.ico": [],
        "[project]/node_modules/.pnpm/next@16.1.6_@babel+core@7.29.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/next/dist/client/components/builtin/global-error": [],
        "[project]/app/page-240/page": []
    },
    "entryJSFiles": {
        "[project]/app/favicon.ico": ["static/chunks/33074d3ff5d0cd2d.js", "static/chunks/eb1e789fab5a5185.js"],
        "[project]/node_modules/.pnpm/next@16.1.6_@babel+core@7.29.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/next/dist/client/components/builtin/global-error": [],
        "[project]/app/page-240/page": ["static/chunks/ac1a1e8b1e840533.js"]
    }
};        

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 10, 2026

🦋 Changeset detected

Latest commit: 8371be5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@opennextjs/cloudflare Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 10, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@opennextjs/cloudflare@1186

commit: 8371be5

@vicb vicb changed the title Factor large repeated values in manifests [PENDING VALIDATION] Factor large repeated values in manifests Apr 10, 2026
jkahn117 pushed a commit to jkahn117/opennextjs-cloudflare that referenced this pull request Apr 15, 2026
…ry files, and chunks arrays

- Replace empty edgeSSRModuleMapping/edgeRscModuleMapping with shared __EMPTY variable
- Factor entryCSSFiles and entryJSFiles through existing factorManifestValue
- Deduplicate repeated chunks arrays within module mappings into shared c_<hash> variables
Builds on opennextjs#1186 (vicb/dedup).
Copy link
Copy Markdown
Collaborator

@conico974 conico974 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving to unblock, but I feel like this is not the right solution.
Maybe we could use a proxy, to keep a single map of values ?

@vicb
Copy link
Copy Markdown
Contributor Author

vicb commented Apr 20, 2026

Maybe we could use a proxy, to keep a single map of values ?

I was not sure if all the values are shared for the same key across different routes.
Do you confirm it is the case?
If you are not completely sure, we can merge this as is and ask the Next tem.
Thanks

@conico974
Copy link
Copy Markdown
Collaborator

@vicb Yeah I'm not sure either, but I don't think it is the case every time.
Not sure yet what would be a good solution for that if that's the case

@vicb
Copy link
Copy Markdown
Contributor Author

vicb commented Apr 21, 2026

See #1215 instead

@vicb vicb closed this Apr 21, 2026
@vicb vicb deleted the vicb/dedup branch April 23, 2026 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants